#!/bin/bash
# TEST SUITE 1
# Set-up: 1 middle man with 1 queue, 1 postgresql server
# Purpose: Try to find out the optimal M number of threads on the middle man


# CONFIGURATION BEGINS HERE

# the folder where results should be stored (relative to home)
results_folder='1m_1s'

middle_man_host='dryad09.inf.ethz.ch'
db_host='dryad08.inf.ethz.ch'

#duration in minutes
duration=10




# AUTOMATIC ITERATION BEGINS HERE
if [ ! -d $results_folder ]; then
	mkdir $results_folder
fi
L=100
P=1

for C in 64
do
	for M in 1 2 4 8 16 32 64
	do
		if [ $M -le $C ]
		then
			out_file_path="$results_folder/c"$C"_p"$P"_l"$L"_m"$M".raw"
			if [ ! -f $out_file_path ]; then
				middle_man_config="{{middle_man:$middle_man_host};{{P:$P},{L:$L},{M:$M},{database:$db_host}}}"
				args="$C $duration $out_file_path 1 $middle_man_config"
				./client.sh $args
			fi
		fi
	done
done